<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<script>
  $(function () {
    $("#examApplyTable").treeTable();
  })
  function selectLabApply(applyId,name,patId,visitId){
    $("#applyId").val(applyId) ;
    $("#name").val(name) ;
    $("#patientId").val(patId) ;
      $("#visitId").val(visitId) ;
  }
  $('#printLabApply').click(function(){
        var applyId = $("#applyId").val();
        var patientId = $("#patientId").val();
        var visitId = $("#visitId").val() ;
        if(applyId=="" || patientId==''){
            toastr.error('请先选择要打印的相应病人的检验单！');
        }else{
            printPdf("${ctx}/nurse/printLabApply","id="+applyId+"&patientId="+patientId+"&visitId="+visitId)
        }
  })
</script>
<div class="app">
  <div class="content-wrap">
    <ul class="nav nav-tabs">
      <li><a href="#" onclick="loadDiv('nurseIndexDiv','${ctx}/nurse/index')">床位列表</a></li>
      <li class="active">
        <a href="#">检验单</a>
      </li>
    </ul>
    <section class="panel panel-default">
      <div class="panel-body">
        <div class="table-responsive no-border">
          <div class="datatable-top">
            <div class="pull-left">
              <form  id="labApplyForm" onsubmit="return loadDivForm('nurseIndexDiv','labApplyForm','${ctx}/nurse/labApply');" method="post" class="form-inline">
                <label>申请时间：</label><input value="${startDate}" name="startDate" class="form-control Wdate" id="startDate" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});">至<input class="form-control Wdate"id="endDate" value="${endDate}" name="endDate" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});">
                <input name="date" id="week" class="btn btn-default" type="button" value="一周内" onclick="dateCondition('week',-7,'startDate')"/>
                <input name="date" id="halfMonth" class="btn btn-default" type="button" value="半月内" onclick="dateCondition('halfMonth',-15,'startDate')"/>
                <input name="date"  id="month" class="btn btn-default" type="button" value="一个月内" onclick="dateCondition('month',-30,'startDate')"/>
                <input  class="btn btn-primary" type="submit" value="查询"/>
                &nbsp;&nbsp;<input class="btn btn-primary" type="submit" id="printLabApply" value="打印"/>
              </form>
            </div>
          </div>
          <input type="hidden" id="applyId" value="">
          <input type="hidden" id="name" value="">
          <input type="hidden" id="patientId" value="">
          <input type="hidden" id="visitId" value="">
          <table id="examApplyTable" class="table table-bordered mg-t datatable">
            <thead>
            <tr>
              <th>检验序号</th>
              <th>申请时间</th>
              <th>姓名</th>
              <th>性别</th>
              <th>确认标志</th>
            </tr>
            </thead>
            <tbody>
            <c:forEach items="${page.list}" var="labApply" varStatus="ex">
              <tr style="cursor: pointer" onclick = selectLabApply('${labApply.id}','${labApply.patMasterIndex.name}','${labApply.patMasterIndex.id}','${labApply.visitId}') id="${labApply.id}">
                <td>${labApply.applyOn}<input type="hidden" value="${labApply.id}"/> </td>
                <td><fmt:formatDate value="${labApply.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/><input type="hidden" value="${labApply.patMasterIndex.id}"/></td>
                <td>${labApply.patMasterIndex.name}</td>
                <td>${fns:getDictLabels(labApply.patMasterIndex.sex, 'SEX_DICT', '')}</td>
                <td><c:if test="${labApply.confirmFlag=='0'}">未确认</c:if>
                  <c:if test="${labApply.confirmFlag=='1'}">已确认</c:if>
                </td>
              </tr>
              <c:if test="${labApply.labItemList.size()>0}">
                <tr id="${ex.count}" pid="${labApply.id}">
                  <td colspan="5">
                    <table class="table table-bordered mg-t">
                      <tr>
                        <th>检验项目</th>
                        <th>项目代码</th>
                        <th>价格</th>
                      </tr>
                      <c:forEach items="${labApply.labItemList}" var="labItems" varStatus="ss">
                        <tr>
                          <td>${labItems.itemName}</td>
                          <td>${labItems.itemCode}</td>
                          <td>${labItems.costs}</td>
                        </tr>
                      </c:forEach>
                    </table>
                  </td>
                </tr>
              </c:if>
            </c:forEach>
            </tbody>
          </table>
          <div class="pagination">${page}</div>
        </div>
      </div>
    </section>
  </div>
</div>
</div>
</div>